package org.paysim.order.controller;

import java.util.List;

import org.paysim.constant.ResponseMessage;
import org.paysim.order.model.OrderCancelRequest;
import org.paysim.order.model.OrderCancelResponse;
import org.paysim.order.model.OrderCreateRequest;
import org.paysim.order.model.OrderCreateResponse;
import org.paysim.order.model.OrderDetailResponse;
import org.paysim.order.model.OrderDetailResponseData;
import org.paysim.order.model.OrderListResponse;
import org.paysim.order.model.OrderResponseData;
import org.paysim.order.service.IOrderService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

@RestController
@RequestMapping("${openapi.paySim.base-path:}")
public class OrderApiController implements OrderApi {

    @Resource
    private IOrderService orderService;

    public ResponseEntity<OrderCreateResponse> orderCreatePost(@Valid OrderCreateRequest orderCreateRequest) {
        OrderResponseData order = orderService.createOrder(orderCreateRequest);

        OrderCreateResponse orderCreateResponse = new OrderCreateResponse().code(ResponseMessage.SUCCESS.getCode())
                .message(ResponseMessage.SUCCESS.getMessage()).data(order);
        return ResponseEntity.ok(orderCreateResponse);
    }

    @Override
    public ResponseEntity<OrderCancelResponse> orderCancelPost(@Valid OrderCancelRequest orderCancelRequest) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResponseEntity<OrderDetailResponse> orderDetailGet(@NotNull @Valid String orderId, @Valid String expand,
            @Valid Object body) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResponseEntity<OrderListResponse> orderListGet(@NotNull @Valid String userId) {
        List<OrderDetailResponseData> orderList = orderService.getOrderList(userId);
        OrderListResponse orderListResponse = new OrderListResponse().code(ResponseMessage.SUCCESS.getCode())
                .message(ResponseMessage.SUCCESS.getMessage()).data(orderList);
        return ResponseEntity.ok(orderListResponse);
    }

}
